package cn.order.controller;

import cn.order.api.StockApi;
import cn.order.entity.Order;
import cn.order.service.OrderServiceImpl;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author summit
 * @since 2022/5/27 14:52
 */
@RestController
@Slf4j
public class OrderController {

    @Autowired
    private OrderServiceImpl orderService;

    @Autowired
    private StockApi stockApi;


    @GetMapping("/test")
    @GlobalTransactional
    public void test(@RequestParam String name) {
        log.info(name);

        Order order = new Order();
        order.setId(1L);
        order.setOrderName("测试");
        order.setStockId(1L);

        stockApi.stock(1L);
        int a = 1 / 0;
    }
}
